import request from '../../utils/request'
import {download} from '../../utils/commons'

/**
 * 分页获取退税列表
 * @param orderno
 * @param declaratNo
 * @param drawbackFianceStatus
 * @param presentStatus
 * @param transferAccountStatus
 * @param exportStart
 * @param exportEnd
 * @param users
 * @param page
 * @returns {Promise.<void>}
 */
export async function getStatusesList({orderNo, contractNo, declaratNo, drawbackFianceStatus, presentStatus, transferAccountStatus, cstName, exportStart, exportEnd, users, page}) {

    /**
     * TODO
     * @type {number}
     */
    users = 1;
    return request(apiPath.mc + "/api/tax/statuses", {
        method: 'get',
        data: {
            orderNo,
            contractNo,
            declaratNo,
            drawbackFianceStatus,
            presentStatus,
            transferAccountStatus,
            exportStart,
            exportEnd,
            users,
            cstName,
            page: page.page, size: page.size
        }
    });
}


/**
 * 修改退税状态
 * @param orderId
 * @param memo
 * @param checkStatus
 * @returns {Promise.<void>}
 */
export async function submittransferstatus({id, presenttime, transferaccountstatus}) {
    return request(apiPath.mc + "/api/tax/submittransferstatus", {
        method: 'put',
        data: {id, presenttime, transferaccountstatus}
    });
}

/**
 * 交单
 * @param id
 * @returns {Promise.<void>}
 */
export async function submitpresentstatus({id, presenttime}) {
    return request(apiPath.mc + "/api/tax/submitpresentstatus", {
        method: 'put',
        data: {orderId : id, presenttime}
    });
}

/**
 *  获取退税详情
 * @param orderId
 * @returns {Promise.<void>}
 */
export async function taxStatusDetail({orderId}) {
    return request(apiPath.mc + "/api/tax/taxStatusDetail", {
        method: 'get',
        data: {orderId}
    });

}


/**
 * 导出退税状态列表
 * @param orderNo
 * @param declaratNo
 * @param drawbackFianceStatus
 * @param presentStatus
 * @param transferAccountStatus
 * @param exportStart
 * @param exportEnd
 * @returns {Promise<void>}
 */
export async function exportTaxStatusList({orderNo, declaratNo, drawbackFianceStatus, presentStatus, transferAccountStatus, exportStart, exportEnd, contractNo, cstName}) {
    let url =  apiPath.mc + "/api/report/taxinv/export";

    download(url, {orderNo, declaratNo, drawbackFianceStatus, presentStatus, transferAccountStatus, exportStart, exportEnd, contractNo, cstName, filename: '退税融资款信息表'});

}